﻿#ifndef __AVOID_CONTROL_PROGRESS_HEAD_FILE_INCLUDED__
#define __AVOID_CONTROL_PROGRESS_HEAD_FILE_INCLUDED__
#include "control.h"
#include "interface/IRound.h"
#include <atomic>

namespace swui
{
#pragma warning(push)
#pragma warning(disable:4250)
	/* ctlProgress 是进度条
	 * 当进度变化时会发出 scroll 事件 */
	class ctlProgress : virtual public ctlRoot, public IRound
	{
	public:
		static const ctlControlType uniqueType = ctlControlType::ctlProgress;
	public:
		virtual ~ctlProgress() { destroy(); }
		bool create(ctlRoot* parent, ctlRect rect,   
			ctlScrollDirection dir = ctlScrollDirection::horizontal, 
			const ctlStyleProgress& style = ctlStyleProgress(ctlStyleProgress::common));
	public:
		//设置或获取逻辑上的最大距离
		bool setMaxLogicLength(int length);
		int getMaxLogicLength();
		//设置或获取百分比
		bool setPercentProgress(float percent);
		float getPercentProgress();
		//设置或获取逻辑距离
		virtual bool setLogicProgress(int logicProgress);
		int getLogicProgress();
	public:
		//获取进度条的方向
		ctlScrollDirection getBarDirection();
	protected:
		virtual void _redraw_(_ctlInterior::drawInfo *);
	private:
		std::atomic_int _progress_scrolled_logic_length;
		int _progress_logic_length;
		ctlScrollDirection _progress_direction;
	};
#pragma warning(pop)
}

#endif